﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace MuaBanLike.com
{
    public partial class MainWindow : Window
    {
        private bool onLogin()
        {
            var doc = (mshtml.HTMLDocument)MainBrowser.Document;
            var coll = doc.getElementsByTagName("input");

            mshtml.HTMLInputElement itemLogin = null;
            int nAddtion = 0;
            foreach (mshtml.HTMLInputElement item in coll)
            {
                if (item != null)
                {
                    if (item.type == "text" && item.name == "login")
                    {
                        item.focus();
                        item.value = m_sUser;
                        nAddtion++;
                    }
                    else if (item.type == "password" && item.name == "pass")
                    {
                        item.focus();
                        item.value = m_sPassWord;
                        nAddtion++;
                    }
                    else if (item.type == "submit")
                    {
                        itemLogin = item;
                        nAddtion++;
                    }
                    if (nAddtion == 3)
                        break;
                }
            }

            if (itemLogin != null)
            {                
                showBallon(m_mainWeb.ToString(), "start login" + m_sUser);               
                itemLogin.click();
                return true;
            }

            return false;
        }
    }
}
